Skip to content

Conversation

@gmorales96
Copy link

@gmorales96 gmorales96 commented Aug 11, 2025

Summary by CodeRabbit

  • New Features
    • Proof-of-life now recognizes both liveness and selfie steps, uses the most recent applicable result, and exposes the related media URL when available.
  • Bug Fixes
    • Proof-of-life errors now include issues from both liveness and selfie steps.
  • Tests
    • Added assertions to verify the proof-of-life media URL is present when available and absent when not.
  • Chores
    • Updated application version to 2.0.8.

@coderabbitai
Copy link

coderabbitai bot commented Aug 11, 2025

Walkthrough

The Verification class now treats steps with id 'selfie' the same as 'liveness': proof_of_life_document returns the last step whose id is in ['liveness', 'selfie'], proof_of_life_errors aggregates errors from both step types, and a new public property proof_of_life_url returns video_url or selfie_photo_url from that step. The package version in mati/version.py was bumped from '2.0.7' to '2.0.8'. Tests were updated to assert that verification.proof_of_life_url is truthy for a full verification and falsy when no liveness/selfie step exists.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested reviewers

  • felipao-mx

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-selfie-support

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
mati/resources/verifications.py (1)

93-105: Include selfie errors and simplify error dict access

To align with the new selfie support in proof_of_life_document, also surface selfie errors here. While at it, avoid repeated 'in' checks by using .get(...).

     def proof_of_life_errors(self) -> List[Errors]:
-        return [
-            Errors(
-                identifier=pol.id,
-                type=pol.error['type'] if 'type' in pol.error else None,
-                code=pol.error['code'] if 'code' in pol.error else None,
-                message=pol.error['message']
-                if 'message' in pol.error
-                else None,
-            )
-            for pol in self.steps  # type: ignore
-            if pol.id == 'liveness' and pol.error
-        ]
+        return [
+            Errors(
+                identifier=pol.id,
+                type=pol.error.get('type'),
+                code=pol.error.get('code'),
+                message=pol.error.get('message'),
+            )
+            for pol in (self.steps or [])  # type: ignore
+            if pol.id in ('liveness', 'selfie') and pol.error
+        ]
🧹 Nitpick comments (1)
mati/resources/verifications.py (1)

85-89: Use membership test for brevity and readability

Simplify the condition to use an in-check.

-        pol = [
-            pol
-            for pol in self.steps
-            if (pol.id == 'liveness' or pol.id == 'selfie')
-        ]
+        pol = [pol for pol in self.steps if pol.id in ('liveness', 'selfie')]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4481946 and 0d3929c.

📒 Files selected for processing (2)
  • mati/resources/verifications.py (1 hunks)
  • mati/version.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

`*...

Files:

  • mati/resources/verifications.py
  • mati/version.py
🔇 Additional comments (2)
mati/resources/verifications.py (1)

82-90: No changes needed: selfie steps use Liveness
Since __post_init__ maps every entry in self.steps through Liveness._from_dict, both "liveness" and "selfie" IDs become Liveness instances with status, error, etc. The return type Optional[Liveness] is therefore accurate.

mati/version.py (1)

1-1: Version bump looks good

Version updated to 2.0.8; aligns with the new selfie support change.

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.16%. Comparing base (4481946) to head (31198a4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
+ Coverage   98.13%   98.16%   +0.03%     
==========================================
  Files          12       12              
  Lines         375      382       +7     
==========================================
+ Hits          368      375       +7     
  Misses          7        7              
Flag Coverage Δ
unittests 98.16% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
mati/resources/verifications.py 100.00% <100.00%> (ø)
mati/version.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4481946...31198a4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmorales96 gmorales96 requested a review from rogelioLpz August 13, 2025 19:30
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
mati/resources/verifications.py (1)

95-108: Refactor to EAFP for nested dict access and handle None steps.

Aligns with the coding guideline to use try/except for nested dict keys and avoids iterating over None. Also reuse the shared step IDs constant.

Apply this diff:

     @property
     def proof_of_life_errors(self) -> List[Errors]:
-        return [
-            Errors(
-                identifier=pol.id,
-                type=pol.error['type'] if 'type' in pol.error else None,
-                code=pol.error['code'] if 'code' in pol.error else None,
-                message=pol.error['message']
-                if 'message' in pol.error
-                else None,
-            )
-            for pol in self.steps  # type: ignore
-            if pol.id in ['liveness', 'selfie'] and pol.error
-        ]
+        if not self.steps:
+            return []
+        errors: List[Errors] = []
+        for step in self.steps:
+            if step.id in self._POL_STEP_IDS and step.error:
+                try:
+                    err_type = step.error['type']
+                except (KeyError, TypeError):
+                    err_type = None
+                try:
+                    code = step.error['code']
+                except (KeyError, TypeError):
+                    code = None
+                try:
+                    message = step.error['message']
+                except (KeyError, TypeError):
+                    message = None
+                errors.append(
+                    Errors(
+                        identifier=step.id,
+                        type=err_type,
+                        code=code,
+                        message=message,
+                    )
+                )
+        return errors
♻️ Duplicate comments (1)
mati/resources/verifications.py (1)

95-108: Including 'selfie' in proof_of_life_errors addresses the prior review.

Good catch extending the filter to include selfie steps.

🧹 Nitpick comments (2)
mati/resources/verifications.py (1)

85-86: Avoid magic strings; extract step IDs constant and fix shadowing for readability.

Prevents duplication across methods and avoids confusing reuse of the variable name "pol". Use a shared constant and a clearer local name.

Apply this diff:

-        pol = [pol for pol in self.steps if pol.id in ['liveness', 'selfie']]
-        return pol[-1] if pol else None
+        life_steps = [step for step in self.steps if step.id in self._POL_STEP_IDS]
+        return life_steps[-1] if life_steps else None

Add this class constant (outside the selected range, near the top of the class):

# Inside class Verification, after _endpoint
_POL_STEP_IDS: ClassVar[tuple] = ('liveness', 'selfie')
tests/resources/test_verifications.py (1)

24-24: LGTM; add a complementary negative case to harden coverage.

Consider asserting that proof_of_life_url is falsy when steps are absent (empty and None) to prevent regressions.

Add these assertions in existing tests (outside the selected range):

# In test_verification_without_liveness
verification.steps = []
assert not verification.proof_of_life_url

# In test_verification_without_pol
verification.steps = None
assert not verification.proof_of_life_url

I can push a patch if you prefer.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb18fcd and 5b787a9.

📒 Files selected for processing (3)
  • mati/resources/verifications.py (2 hunks)
  • mati/version.py (1 hunks)
  • tests/resources/test_verifications.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • mati/version.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

`*...

Files:

  • tests/resources/test_verifications.py
  • mati/resources/verifications.py
🧬 Code Graph Analysis (1)
tests/resources/test_verifications.py (2)
tests/conftest.py (1)
  • verification (217-222)
mati/resources/verifications.py (1)
  • proof_of_life_url (89-93)

rogelioLpz
rogelioLpz previously approved these changes Aug 14, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
mati/version.py (1)

1-1: Optional: add a type hint for version to aid tooling.

Minor improvement for editor/type-checker friendliness.

-__version__ = '2.0.8'
+__version__: str = '2.0.8'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 57cf17c and 31198a4.

📒 Files selected for processing (1)
  • mati/version.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

`*...

Files:

  • mati/version.py
🔇 Additional comments (2)
mati/version.py (2)

1-1: LGTM: Version bumped to 2.0.8 (PEP 440-compliant).

Patch bump aligns with the PR scope. No functional concerns in this file.


1-1: Single source of truth confirmed ✅

  • __version__ = '2.0.8' is defined only in mati/version.py.
  • setup.py loads that value via SourceFileLoader and uses it in setup(version=…).
  • No other hard-coded version = entries found in setup.cfg or (nonexistent) pyproject.toml.
  • __version__ is re-exported in mati/__init__.py.

No further changes needed.

@rogelioLpz rogelioLpz merged commit 554d1c4 into master Aug 15, 2025
11 checks passed
@rogelioLpz rogelioLpz deleted the add-selfie-support branch August 15, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants